(* randombuild.ml : Construction aléatoire d'arbre *)
 
let visible_char () =
  let asci = Random.int 94 in
    Char.chr (asci + 33)
 
let string l =
  let s = String.create l in
    for i = 0 to l-1 do
      s.[i] <- visible_char ()
    done; s
 
let rec full gen = function
    -1 -> Tree.empty
  | n ->
      Tree.node (full gen (n-1)) (gen ()) (full gen (n-1))
 
let int_full d = full (fun _ -> Random.int 100) d
 
let char_full d = full visible_char d
 
let string_full d = full (fun _ -> string 5) d
 
let rec part gen = function
    d when d<0 -> Tree.empty
  | 0 -> Tree.node Tree.empty (gen ()) Tree.empty
  | d ->
      Tree.node
	(part gen (d - (1 + Random.int d)))
	(gen ())
	(part gen (d - (1 + Random.int d)))
 
let int_part d = part (fun _ -> Random.int 100) d
 
let char_part d = part visible_char d
 
let string_part d = part (fun _ -> string 5) d

